<include file="public@header" />
</head>
<body o>
	<div class="wrap ">
		<ul class="nav nav-tabs">
			<li><a href="{:url('goods/index',array('type'=>$type))}">{$goods_name_menu}</a></li>
			<li><a href="{:url('goods/add',array('type'=>$type))}">{$goods_name_add}</a></li>
			<li class="active"><a href="{:url('goods/edit', array('id' => $id,'type'=>$type))}">{$goods_name_edit}</a></li>
		</ul>
		<form class="form-horizontal js-ajax-form" action="{:url('Goods/edit_post')}" method="post" enctype="multipart/form-data">
			<input type="hidden" name="type" value="{$type}" />
			<input type="hidden" name="id" value="{$id}">
            <fieldset>
				<if condition="$type eq 1">
				<div class="control-group">
					<label class="control-label">物料编号</label>
					<div class="controls">
						<input type="text" class="form-control" name="goods_name" value="{$goods_num}" id="goods_num" readonly/>
					</div>
				</div>
				</if>
				<div class="control-group">
					<label class="control-label">{:lang('GOODS_NAME')}</label>
					<div class="controls">
						<input :type="text" class="form-control" name="goods_name" value="{$goods_name}" id="goods_name"/>
						<span class="form-required">*</span>
					</div>
				</div>
                <div class="control-group">
					<label class="control-label">商品分类</label>
					<div class="controls">
						<select class="form-control" <if condition="$type neq null">readonly name="type"<else/>name="cate_p_id"</if>>
						<if condition="$type neq null">
							<option value="2" <if condition="$type eq 2">selected</if>>固定资产</option>
							<option value="1" <if condition="$type eq 1">selected</if>>物料</option>
							<else/>
							<volist name="cates" id="vo">
								<option value="{$vo.id}" <if condition="$cate_p_id eq $vo.id">selected</if>>{$vo.cate_name}</option>
							</volist>
						</if>
						</select>
					</div>
				</div>
				<div class="control-group normal">
					<label class="control-label">单价</label>
					<div class="controls">
						<input :type="text" class="form-control" name="price" value="{$price}" id="price" required/>
						<span class="form-required">*</span>
					</div>
				</div>
				<if condition="$type eq 1">
					<div class="control-group">
						<label class="control-label">单位</label>
						<div class="controls">
							<input :type="text" class="form-control" name="price_unit" value="{$price_unit}" required/>
							<span class="form-required">*</span>
						</div>
					</div>
				</if>
				<if condition="$type neq ''">
				<div class="control-group">
					<label class="control-label">{:lang('STOREROOM')}</label>
					<div class="controls">
						<select name="room" class="form-control">
							<volist name="rooms" id="vo">
								<option value="{$vo.id}" <if condition="$room eq $vo.id">selected</if>>{$vo.room_name}</option>
							</volist>
						</select>
					</div>
				</div>
				</if>
				<if condition="$type neq 1">
                <div class="control-group">
					<label class="control-label">{:lang('数量')}</label>
					<div class="controls">
						<input :type="text" class="form-control" name="stock" value="{$stock}" id="stock"/>
                        <span class="form-required">*</span>
					</div>
				</div>
				</if>
				<div class="control-group">
					<label class="control-label">{:lang('供货商')}</label>
					<div class="controls">
						<input type="text" class="form-control" name="service" value="{$service}"/>
					</div>
				</div>
                <div class="control-group">
					<label class="control-label">排序</label>
					<div class="controls">
						<input :type="text" class="form-control" name="listorder" value="{$listorder}"/>
                        <span class="form-required">商品默认升序排序</span>
					</div>
				</div>
				<if condition="$type neq 1">
                <div class="control-group">
					<label class="control-label">{:lang('封面图片')}</label>
					<div class="controls">
						<php>$img_url=cmf_get_image_preview_url($photos_url);</php>
                        <input type="hidden" name="photos_url" id="photos_url" value="">
                        <img height="36" src="{$img_url}" class="preview" id="photos_url-preview" />
						<a class="btn btn-primary" onClick="uploadOneImage('商品图片', '#photos_url')">{:lang("UPLOAD")}</a>
						<span class="form-required">*</span>
					</div>
				</div>
				</if>
                <div class="control-group">
					<label class="control-label">{:lang('商品描述')}</label>
					<div class="controls">
						<textarea name="description" class="form-control" style="width:400px;height:100px;"/>{$description}</textarea>
					</div>
				</div>
			</fieldset>
			<div class="form-actions">
				<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
				<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
			</div>
		</form>
	</div>
    <admintpl file="Goods/include"/>
	<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
     <script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=ZZMBZ-MK23R-5IIWW-WQGIM-VX6J2-54BB4"></script>
		<script type="text/javascript">
        $("#btn").click(function(){
            upload_one("视频上传", "#video_path", "video");
        });
		
    </script>
	<script type="text/javascript">
		var a,b,c,d;
		$('.if_salerange').click(function(){
			var chooseval=$(this).val();
			if(chooseval==2){
				$('#sale_range').show();
			}else{
				$('#sale_range').hide();
			}
		})
		$('.if_postage').click(function(){
			var chooseval=$(this).val();
			if(chooseval==1){
				$('.postage').show();
			}else{
				$('.postage').hide();
			}
		})
		var init = function() {
		    a=$('#Latitude').val();
		    b=$('#Longitude').val();
			if(a==''){
				// 接收位置信息
				a=35.871247;
				b=117.806396; 
			}
		var center = new qq.maps.LatLng(a,b);
		var map = new qq.maps.Map(document.getElementById("container"),{
			center: new qq.maps.LatLng(a,b),
			zoom: 4
		});
		 var markers= new qq.maps.Marker({
			position: center,
			draggable: true,
			map: map
		});
		//绑定单击事件添加参数
		 //添加监听事件   获取鼠标单击事件
		qq.maps.event.addListener(markers, 'mouseup', function(event) {
				$('#Latitude').val(event.latLng.getLat());
				$('#Longitude').val(event.latLng.getLng());
		});
		var jump = function(event) {
			markers.setPosition(event.latLng);
			$('#Latitude').val(event.latLng.getLat());
			$('#Longitude').val(event.latLng.getLng());
		};
	
		qq.maps.event.addListener(map, 'click', jump);
	
		}
	</script>
</body>
</html>